home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / misc / Disk.man < prev    next >
Encoding:
Text File  |  1991-11-15  |  30.1 KB  |  531 lines

  1.  
  2.  
  3.  
  4. Disk                  C Library Procedures                   Disk
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NNAAMMEE
  11.      Disk_ReadLabel,      Disk_WriteLabel,       Disk_EraseLabel,  |
  12.      Disk_NewLabel,     Disk_ReadDecLabel,    Disk_WriteDecLabel,  |
  13.      Disk_ReadSunLabel,  Disk_WriteSunLabel,  Disk_HasFilesystem,  |
  14.      Disk_ReadLfsSuperBlock,             Disk_WriteLfsSuperBlock,  |
  15.      Disk_ReadLfsCheckpointHdr,       Disk_WriteLfsCheckPointHdr,  |
  16.      Disk_WriteLfsCheckPointArea,      Disk_LfsCheckpointTrailer,  |
  17.      Disk_ForEachCheckpointRegion,         Disk_ReadDomainHeader,  |
  18.      Disk_WriteDomainHeader,                Disk_ReadSummaryInfo,  |
  19.      Disk_WriteSummaryInfo,  Disk_SectorRead,   Disk_SectorWrite,  |
  20.      Disk_BlockRead,      Disk_BlockWrite,     Disk_BadBlockRead,  |
  21.      Disk_FragRead,    Disk_FragWrite,    Disk_PrintDomainHeader,  |
  22.      Disk_PrintSummaryInfo,             Disk_PrintFileDescBitmap,  |
  23.      Disk_PrintDataBlockBitmap,               Disk_PrintDirEntry,  |
  24.      Disk_PrintLabel,                    Disk_PrintLfsSuperBlock,  |
  25.      Disk_PrintLfsSuperBlockHdr,      Disk_PrintLfsDescMapParams,  |
  26.      Disk_PrintLfsSegUsageParams,  Disk_PrintLfsFileLayoutParams,  |
  27.      Disk_PrintLfsStableMemParams,    Disk_PrintLfsCheckpointHdr,  |
  28.      Disk_PrintLfsCheckpointRegion,  |
  29.      Disk_PrintLfsCheckpointTrailer - Package for  accessing  OFS  |
  30.      and LFS file systems via raw disks
  31.  
  32. SSYYNNOOPPSSIISS
  33.      #include <disk.h>                                             |
  34.      Disk_Label *                                                  |
  35.      DDiisskk__RReeaaddLLaabbeell(_f_i_l_e_I_D)                                        |
  36.      int                                                           |
  37.      DDiisskk__WWrriitteeLLaabbeell(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r)                             |
  38.      Disk_Label *                                                  |
  39.      DDiisskk__NNeewwLLaabbeell(_l_a_b_e_l_T_y_p_e)                                      |
  40.      int                                                           |
  41.      DDiisskk__EErraasseeLLaabbeell(_f_i_l_e_I_D, _l_a_b_e_l_T_y_p_e)                            |
  42.      Dec_DiskLabel *                                               |
  43.      DDiisskk__RReeaaddDDeeccLLaabbeell(_f_i_l_e_I_D)                                     |
  44.      int                                                           |
  45.      DDiisskk__WWrriitteeDDeeccLLaabbeell(_f_i_l_e_I_D, _d_e_c_L_a_b_e_l_P_t_r)                       |
  46.      Sun_DiskLabel *
  47.      DDiisskk__RReeaaddSSuunnLLaabbeell(_f_i_l_e_I_D)
  48.      int                                                           |
  49.      DDiisskk__WWrriitteeSSuunnLLaabbeell(_f_i_l_e_I_D, _s_u_n_L_a_b_e_l_P_t_r)                       |
  50.      Ofs_DomainHeader *                                            |
  51.      DDiisskk__RReeaaddDDoommaaiinnHHeeaaddeerr(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r)                       |
  52.      int                                                           |
  53.      DDiisskk__WWrriitteeDDoommaaiinnHHeeaaddeerr(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r, _h_e_a_d_e_r_P_t_r)           |
  54.      Ofs_SummaryInfo *                                             |
  55.      DDiisskk__RReeaaddSSuummmmaarryyIInnffoo(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r)                        |
  56.      int                                                           |
  57.      DDiisskk__WWrriitteeSSuummmmaarryyIInnffoo(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r, _s_u_m_m_a_r_y_P_t_r)           |
  58.      int
  59.      DDiisskk__SSeeccttoorrRReeaadd(_f_i_l_e_I_D, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
  60.  
  61.  
  62.  
  63. Sprite v.1.0       Printed:  November 15, 1991                  1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Disk                  C Library Procedures                   Disk
  71.  
  72.  
  73.  
  74.      int
  75.      DDiisskk__SSeeccttoorrWWrriittee(_f_i_l_e_I_D, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
  76.      int
  77.      DDiisskk__BBlloocckkRReeaadd(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
  78.      int
  79.      DDiisskk__BBlloocckkWWrriittee(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
  80.      int
  81.      DDiisskk__BBaaddBBlloocckkRReeaadd(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _b_u_f_f_e_r)
  82.      int
  83.      DDiisskk__FFrraaggRReeaadd(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
  84.      int
  85.      DDiisskk__FFrraaggWWrriittee(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
  86.      void
  87.      DDiisskk__PPrriinnttDDoommaaiinnHHeeaaddeerr(_h_e_a_d_e_r_P_t_r)
  88.      void
  89.      DDiisskk__PPrriinnttSSuummmmaarryyIInnffoo(_s_u_m_m_a_r_y_P_t_r)
  90.      DDiisskk__PPrriinnttLLaabbeell(_l_a_b_e_l_P_t_r)                                     |
  91.      void
  92.      DDiisskk__PPrriinnttFFiilleeDDeessccBBiittmmaapp(_h_e_a_d_e_r_P_t_r, _b_i_t_m_a_p)
  93.      void
  94.      DDiisskk__PPrriinnttDDaattaaBBlloocckkBBiittmmaapp(_h_e_a_d_e_r_P_t_r, _b_i_t_m_a_p)
  95.      void
  96.      DDiisskk__PPrriinnttDDiirrEEnnttrryy(_d_i_r_E_n_t_r_y_P_t_r)
  97.      int                                                           |
  98.      DDiisskk__HHaassFFiilleessyysstteemm(_f_i_l_e_I_D, _l_a_b_e_l_p_t_r)                          |
  99.      LfsSuperBlock*                                                |
  100.      DDiisskk__RReeaaddLLffssSSuuppeerrBBlloocckk(_f_i_l_e_I_d, _l_a_b_e_l_P_t_r)                      |
  101.      ReturnStatus                                                  |
  102.      DDiisskk__WWrriitteeLLffssSSuuppeerrBBlloocckk(_f_i_l_e_I_d, _l_f_s_S_u_p_e_r_P_t_r)                  |
  103.      LfsCheckPointHdr*                                             |
  104.      DDiisskk__RReeaaddLLffssCChheecckkPPooiinnttHHddrr(_f_i_l_e_I_d, _l_a_b_e_l_P_t_r, _a_r_e_a_P_t_r)          |
  105.      ReturnStatus                                                  |
  106.      DDiisskk__WWrriitteeLLffssCChheecckkPPooiinnttHHddrr(_f_i_l_e_I_d, _h_e_a_d_e_r_P_t_r, _a_r_e_a, _l_a_b_e_l_P_t_r) |
  107.      ReturnStatus                                                  |
  108.      DDiisskk__WWrriitteeLLffssCChheecckkPPooiinnttAArreeaa(_f_i_l_e_I_d, _h_e_a_d_e_r_P_t_r, _a_r_e_a, _l_a_b_e_l_P_t_r)|
  109.      LfsCheckPointTrailer*                                         |
  110.      DDiisskk__LLffssCChheecckkPPooiinnttTTrraaiilleerr(_c_h_e_c_k_P_o_i_n_t_H_d_r_P_t_r)                   |
  111.      ReturnStatus                                                  |
  112.      DDiisskk__FFoorrEEaacchhCChheecckkPPooiinnttRReeggiioonn(_c_h_e_c_k_P_o_i_n_t_H_d_r_P_t_r, _r_e_g_i_o_n_P_r_o_c)    |
  113.      void                                                          |
  114.      DDiisskk__PPrriinnttLLffssSSuuppeerrBBlloocckkHHddrr(_l_f_s_S_u_p_e_r_H_d_r_P_t_r)                    |
  115.      void                                                          |
  116.      DDiisskk__PPrriinnttLLffssSSttaabblleeMMeemmPPaarraammss(_s_t_a_b_l_e_M_e_m_P_t_r)                    |
  117.      void                                                          |
  118.      DDiisskk__PPrriinnttLLffssDDeessccMMaappPPaarraammss(_d_e_s_c_M_a_p_P_t_r)                        |
  119.      void                                                          |
  120.      DDiisskk__PPrriinnttLLffssSSeeggUUssaaggeePPaarraammss(_s_e_g_U_s_a_g_e_P_t_r)                      |
  121.      void                                                          |
  122.      DDiisskk__PPrriinnttLLffssFFiilleeLLaayyoouuttPPaarraammss(_f_i_l_e_L_a_y_o_u_t_P_t_r)                  |
  123.      void                                                          |
  124.      DDiisskk__PPrriinnttLLffssSSuuppeerrBBlloocckk(_l_f_s_S_u_p_e_r_P_t_r)                          |
  125.      void                                                          |
  126.  
  127.  
  128.  
  129. Sprite v.1.0       Printed:  November 15, 1991                  2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. Disk                  C Library Procedures                   Disk
  137.  
  138.  
  139.  
  140.      DDiisskk__PPrriinnttLLffssCChheecckkPPooiinnttHHddrr(_c_h_e_c_k_P_o_i_n_t_H_d_r)                     |
  141.      void                                                          |
  142.      DDiisskk__PPrriinnttLLffssCChheecckkPPooiinnttRReeggiioonn(_r_e_g_i_o_n_P_t_r)                      |
  143.      void                                                          |
  144.      DDiisskk__PPrriinnttLLffssCChheecckkPPooiinnttTTrraaiilleerr(_t_r_a_i_l_e_r_P_t_r)                    |
  145.  
  146. AARRGGUUMMEENNTTSS
  147.      int                _f_i_l_e_I_D        (in)      File   descriptor
  148.                                                 from  ooppeenn of raw
  149.                                                 disk.
  150.  
  151.      int                _p_a_r_t_i_t_i_o_n     (in)      Index  of  parti-
  152.                                                 tion  to  access,
  153.                                                 0-7.               |
  154.  
  155.      Disk_Label         *_l_a_b_e_l_P_t_r     (in)                              ||
  156.                                                 Basic disk infor-  |
  157.                                                 mation       from  |
  158.                                                 DDiisskk__RReeaaddLLaabbeell.    |
  159.  
  160.      Disk_NativeLabelType             _l_a_b_e_l_T_y_p_e(in)                     ||
  161.                                                 Type  of machine-  |
  162.                                                 specific (native)  |
  163.                                                 disk label on the  |
  164.                                                 disk.              |
  165.  
  166.      Dec_DiskLabel  *_d_e_c_L_a_b_e_l_P_t_r                                        ||
  167.                                                 Native disk label  |
  168.                                                 for ds3100s.       |
  169.  
  170.      Sun_DiskLabel  *_s_u_n_L_a_b_e_l_P_t_r                                        ||
  171.                                                 Native disk label  |
  172.                                                 for Suns.
  173.  
  174.      int                _i_n_d_e_x         (in)      Index  of   first
  175.                                                 (sector/block/fragment)
  176.                                                 to transfer.
  177.  
  178.      int                _c_o_u_n_t         (in)      Number         of
  179.                                                 (sectors/blocks/fragments)
  180.                                                 to transfer.
  181.  
  182.      char               *_b_u_f_f_e_r       (in)      Buffer  for  data
  183.                                                 transferred.
  184.  
  185.      Ofs_DomainHeader   *_h_e_a_d_e_r_P_t_r    (in)      Disk       header
  186.                                                 information  from
  187.                                                 DDiisskk__RReeaaddDDiisskkHHeeaaddeerr.
  188.  
  189.      Ofs_SummaryInfo    *_s_u_m_m_a_r_y_P_t_r   (in)      Disk      summary
  190.                                                 information  sec-
  191.                                                 tor.
  192.  
  193.  
  194.  
  195. Sprite v.1.0       Printed:  November 15, 1991                  3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. Disk                  C Library Procedures                   Disk
  203.  
  204.  
  205.  
  206.      char               *_b_i_t_m_a_p       (in)      Array  of  bitmap
  207.                                                 bytes.
  208.  
  209.      Fslcl_DirEntry     *_d_i_r_E_n_t_r_y_P_t_r  (in)      Directory   entry
  210.                                                 structure.
  211.  
  212.      LfsSuperBlock      *_l_f_s_S_u_p_e_r_P_t_r  (in)      LFS  Super  Block
  213.                                                 structure.
  214.  
  215.      LfsSuperBlockHdr   *_l_f_s_S_u_p_e_r_H_d_r_P_t_r(in)     Static parameters
  216.                                                 describing    LFS
  217.                                                 layout on disk.
  218.  
  219.      LfsCheckPointHdr   *_c_h_e_c_k_P_o_i_n_t_H_d_r_P_t_r(in)   Structure
  220.                                                 describing    and
  221.                                                 heading   a   LFS
  222.                                                 checkpoint area.
  223.  
  224.      int                _a_r_e_a_P_t_r       (out)     If      non-NULL,
  225.                                                 returns       the
  226.                                                 checkpoint    the
  227.                                                 header is for.
  228.  
  229.      int                _a_r_e_a          (in)      Flag  determining
  230.                                                 the    checkpoint
  231.                                                 area (0 or 1).
  232.  
  233.      LfsCheckPointTrailer             *_t_r_a_i_l_e_r_P_t_r(in)
  234.                                                 Structure capping
  235.                                                 a LFS checkpoinit
  236.                                                 area.
  237.  
  238.      int proc(LfsCheckPointRegion*)   _r_e_g_i_o_n_P_r_o_c(in)
  239.                                                 Procedure used to
  240.                                                 iterate  over the
  241.                                                 various    check-
  242.                                                 point     regions
  243.                                                 between       the
  244.                                                 lfsCheckPointHdr
  245.                                                 and the  lfsChec-
  246.                                                 pointTrailer.
  247.  
  248.      LfsStableMemParams *_s_t_a_b_l_e_M_e_m_P_t_r (in)      Configuration
  249.                                                 parameters    for
  250.                                                 stable     memory
  251.                                                 data structures.
  252.  
  253.      LfsDescMapParams   *_d_e_s_c_M_a_p_P_t_r   (in)      LFS    descriptor
  254.                                                 map   layout   on
  255.                                                 disk.
  256.  
  257.      LfsSegUsageParams  *_s_e_g_U_s_a_g_e_P_t_r  (in)      LFS segment usage
  258.  
  259.  
  260.  
  261. Sprite v.1.0       Printed:  November 15, 1991                  4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. Disk                  C Library Procedures                   Disk
  269.  
  270.  
  271.  
  272.                                                 array      layout
  273.                                                 description    on
  274.                                                 disk.
  275.  
  276.      LfsFileLayoutParams              *_f_i_l_e_L_a_y_o_u_t_P_t_r(in)
  277.                                                 Number  of   file
  278.                                                 descriptors    to
  279.                                                 pack together per
  280.                                                 block.
  281.  
  282. _________________________________________________________________
  283.  
  284.  
  285. IINNTTRROODDUUCCTTIIOONN
  286.      The DDiisskk package is used to read and write  raw  disks  that
  287.      are  formatted to contain Sprite file systems.  To use these
  288.      routines correctly it is important to understand disk _p_a_r_t_i_-
  289.      _t_i_o_n_s,  file  system _h_e_a_d_e_r _i_n_f_o_r_m_a_t_i_o_n, file system _b_l_o_c_k_s,
  290.      and file system block _f_r_a_g_m_e_n_t_s.
  291.  
  292.      Each physical disk is divided into as many as 8  partitions.
  293.      The  letters  'a'  through 'h' are used to distinguish these
  294.      different partitions in the  names  of  the  special  device
  295.      files  that  are  used  to access them.  Thus ``/dev/rsd0a''
  296.      references the first (zero'th) partition on disk  rrssdd00.  The  |
  297.      partitioning information is stored on the disk in the ``disk  |
  298.      label''.  This label is in a machine-dependent  format,  and  |
  299.      is  referred  to  as the ``native disk label''.  Native disk  |
  300.      labels are kept in a machine-dependent location on the disk.  |
  301.      This  is  usually  in sector 0 or some other sector near the  |
  302.      start of the  first  partition.   The  ffssmmaakkee  program  also  |
  303.      copies  the  label  to a partition when it formats it into a  |
  304.      file   system.   The    routines    DDiisskk__RReeaaddSSuunnLLaabbeell    and  |
  305.      DDiisskk__RReeaaddDDeeccLLaabbeell  can  be  used  to  read  the  native disk  |
  306.      labels.                                                       |
  307.  
  308.      It is not always convenient to deal with native disk labels.  |
  309.      For this reason a generic label type and associated routines  |
  310.      have been provided.  The type DDiisskk__LLaabbeell is a standard  for-  |
  311.      mat  for disk labels.  The routine DDiisskk__RReeaaddLLaabbeell is used to  |
  312.      read a native disk label off the disk and convert it into  a  |
  313.      DDiisskk__LLaabbeell.   The  routine  DDiisskk__WWrriitteeLLaabbeell  will  convert a  |
  314.      DDiisskk__LLaabbeell into a native disk label  and  write  it  on  the  |
  315.      disk.   Two  more  procedures  are provided for manipulating  |
  316.      disk labels.  DDiisskk__EErraasseeLLaabbeell will erase a native disk label  |
  317.      from  the  disk,  and  DDiisskk__NNeewwLLaabbeell is used to create a new  |
  318.      label if the disk does not have one already.   The  contents  |
  319.      of a DDiisskk__LLaabbeell are defined in <disk.h>.
  320.  
  321.      DDiisskk__HHaassFFiilleessyysstteemm returns the type of file  system  on  the
  322.      disk.   If  the  disk has a LFS file system, DISK_HAS_LFS is
  323.      returned; if the disk has an OFS file  system,  DISK_HAS_OFS
  324.      is returned; otherwise, DISK_HAS_NO_FS is returned.
  325.  
  326.  
  327.  
  328.  
  329. Sprite v.1.0       Printed:  November 15, 1991                  5
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. Disk                  C Library Procedures                   Disk
  337.  
  338.  
  339.  
  340.      The detailed structure of the  old  sprite  file  system  is
  341.      defined  by  a Ofs_DomainHeader structure that is located on
  342.      the disk according to the DDiisskk__LLaabbeell.  This can be  obtained
  343.      with     the     DDiisskk__RReeaaddDDoommaaiinnHHeeaaddeerr    procedure.     The
  344.      Ofs_DomainHeader structure is  defined  in  <kernel/fsdm.h>,
  345.      and is passed to the block and fragment I/O routines so they
  346.      can correctly locate blocks and fragments.
  347.  
  348.      A secondary data structure called the summary information is  |
  349.      kept  on  disk  following  the  domain  header.  The summary  |
  350.      information consists of a single sector  and  contains  such  |
  351.      information  as  the number of free blocks and file descrip-  |
  352.      tors.   The  Ofs_SummaryInfo   structure   is   defined   in  |
  353.      <kernel/fsdm.h>.   The  location  of  the  summary sector is  |
  354.      stored in the DDiisskk__LLaabbeell.  The summary sector  can  be  read  |
  355.      and    written    using    the    DDiisskk__RReeaaddSSuummmmaarryyIInnffoo   and  |
  356.      DDiisskk__WWrriitteeSSuummmmaarryyIInnffoo procedures.                             |
  357.  
  358.      The detailed structure of a log structured  file  system  is  |
  359.      defined  by a LfsSuperBlock structure whose location on disk  |
  360.      is determined in <kernel/lfsSuperBlock.h>.   This  structure  |
  361.      can  be read off of a disk using DDiisskk__RReeaaddLLffssSSuuppeerrBBlloocckk, and  |
  362.      written using DDiisskk__WWrriitteeSSuuppeerrBBlloocckk.                           |
  363.  
  364.      DDiisskk__RReeaaddLLffssCChheecckkppooiinnttHHddrr returns the current LFS checkpoint  |
  365.      header,  which  is  also  a front for the current checkpoint  |
  366.      area whose bulk is hidden behind  the  LLffssCChheecckkPPooiinnttHHddrr.  If  |
  367.      aarreeaaPPttrr  is non-NULL, the area number that the header is for  |
  368.      gets returned through the pointer.  (The area can be  either  |
  369.      zero  or  one, and only makes a difference if the checkpoint  |
  370.      header  is  going  to  be  written  back   out   to   disk.)  |
  371.      DDiisskk__CChheecckkPPooiinnttTTrraaiilleerr  accesses  the tail of the checkpoint  |
  372.      area    from    a     LLffssCChheecckkPPooiinnttHHddrr     returned     from  |
  373.      DDiisskk__RReeaaddLLffssCChheecckkPPooiinnttHHddrr.  DDiisskk__WWrriitteeLLffssCChheecckkPPooiinnttHHddrr  will  |
  374.      write to disk only the  LLffssCChheecckkPPooiinnttHHddrr  structure  of  the  |
  375.      specified  checkpoint area; DDiisskk__WWrriitteeLLffssCChheecckkPPooiinnttAArreeaa will  |
  376.      write to  disk  the  entire  checkpoint  area  headed  by  a  |
  377.      LLffssCChheecckkPPooiinnttHHddrr,  which  is  larger than just the structure  |
  378.      itself (such as is returned  by  DDiisskk__RReeaaddLLffssCChheecckkPPooiinnttHHddrr).  |
  379.      DDiisskk__FFoorrEEaacchhCChheecckkPPooiinnttRReeggiioonnss  takes  a  procedural argument  |
  380.      and iterates over the LLffssCChheecckkPPooiinnttRReeggiioonnss in the checkpoint  |
  381.      area  headed  by a LLffssCChheecckkPPooiinnttHHddrr, applying the procedural  |
  382.      argument to every region in the  checkpoint  area.   If  the  |
  383.      procedure returns a non-zero value, then the iteration halts  |
  384.      and      that       value       is       returned       from  |
  385.      DDiisskk__FFoorrEEaacchhCChheecckkPPooiinnttRReeggiioonn.                                 |
  386.  
  387. SSEECCTTOORR II//OO                                                         |
  388.      DDiisskk__SSeeccttoorrRReeaadd and DDiisskk__SSeeccttoorrWWrriittee read and write  sectors  |
  389.      from  the disk without regard to the underlying block struc-  |
  390.      ture.  Their  _i_n_d_e_x  argument  specifies  the  first  sector  |
  391.      (starting  from  zero) to transfer, relative to the start of  |
  392.  
  393.  
  394.  
  395. Sprite v.1.0       Printed:  November 15, 1991                  6
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402. Disk                  C Library Procedures                   Disk
  403.  
  404.  
  405.  
  406.      the partition.  The sector offsets given in  the  DDiisskk__LLaabbeell  |
  407.      structure are useful with this routine.                       |
  408.  
  409. BBLLOOCCKK II//OO                                                          |
  410.      The file system is arranged in  block-sized  chunks  on  the  |
  411.      disk.    FFSS__BBLLOOCCKK__SSIIZZEE   defines  how  many  bytes  this  is  |
  412.      (currently 4 Kbytes).  Due to disk  geometry  considerations  |
  413.      consecutive  blocks  may  or  may not be contiguous on disk.  |
  414.      DDiisskk__BBlloocckkRReeaadd and DDiisskk__BBlloocckkWWrriittee use  geometry  and  block  |
  415.      layout  information  in  the  Ofs_DomainHeader  to correctly  |
  416.      locate disk blocks.  The _i_n_d_e_x argument to these routines is  |
  417.      a  block index, counting from the beginning of the partition  |
  418.      (see the warning below!).                                     |
  419.  
  420.      DDiisskk__BBaaddBBlloocckkRReeaadd is used to re-read a bad file system block  |
  421.      and  determine  which sectors are bad.  It returns a bitmask  |
  422.      with bits set to indicate which of the sectors were success-  |
  423.      fully  read.   Bit  _i in the mask corresponds to sector _i in  |
  424.      the block.  DDIISSKK__SSEECCTTOORRSS__PPEERR__BBLLOOCCKK defines how  many  sector  |
  425.      there are in each file system block.                          |
  426.  
  427. FFRRAAGGMMEENNTT II//OO                                                       |
  428.      Each file system block  is  sub-divided  into  fragments  to  |
  429.      optimize  allocation of small files.  Currently the fragment  |
  430.      size is 1 Kbyte, so there are 4  fragments  to  each  block.  |
  431.      DDiisskk__FFrraaggRReeaadd  and DDiisskk__FFrraaggWWrriittee are used to read and write  |
  432.      fragments.  The _i_n_d_e_x argument to these routines is a  frag-  |
  433.      ment  index,  counting  from  the beginning of the partition  |
  434.      (see the warning below!).  The _c_o_u_n_t argument to these  rou-  |
  435.      tines should not be greater than the number of fragments per  |
  436.      file system block.                                            |
  437.  
  438. BBLLOOCCKK AANNDD FFRRAAGGMMEENNTT IINNDDEEXXEESS                                         |
  439.      WWAARRNNIINNGG:: there are several caveats about block  numbers  and  |
  440.      fragment  numbers as used by the Sprite file system.  A par-  |
  441.      tition is divided into areas for bitmaps, file  descriptors,  |
  442.      and  data  blocks.   These  divisions  are  specified in the  |
  443.      Ofs_DomainHeader structure in terms  of  block  offsets  and  |
  444.      number  of  blocks.   However, _b_l_o_c_k _n_u_m_b_e_r_s _a_r_e _n_o_t _k_e_p_t _i_n  |
  445.      _d_i_s_k _m_a_p_s,  _o_n_l_y  _f_r_a_g_m_e_n_t  _n_u_m_b_e_r_s.   When  traversing  the  |
  446.      direct and indirect blocks that define where a file's blocks  |
  447.      are, fragment indexes must be  converted  to  block  indexes  |
  448.      before   using  either  DDiisskk__BBlloocckkRReeaadd  or  DDiisskk__BBlloocckkWWrriittee.  |
  449.      Also, _d_i_r_e_c_t _b_l_o_c_k _p_o_i_n_t_e_r_s _i_n _t_h_e _m_a_p_s _a_r_e _f_r_a_g_m_e_n_t _i_n_d_e_x_e_s  |
  450.      _r_e_l_a_t_i_v_e  _t_o  _t_h_e  _s_t_a_r_t  _o_f _t_h_e _d_a_t_a _b_l_o_c_k _a_r_e_a _o_f _t_h_e _f_i_l_e  |
  451.      _s_y_s_t_e_m.  Thus to convert from a direct block  pointer  to  a  |
  452.      physical fragment index:                                      |
  453.  
  454.           fragIndex = blockPointer + (headerPtr->dataOffset * FS_FRAGMENTS_PER_BLOCK);|
  455.           blockIndex = fragIndex / FS_FRAGMENTS_PER_BLOCK;         |
  456.  
  457.      The last main caveat is that  _i_n_d_i_r_e_c_t  _b_l_o_c_k  _p_o_i_n_t_e_r_s  _a_r_e  |
  458.  
  459.  
  460.  
  461. Sprite v.1.0       Printed:  November 15, 1991                  7
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468. Disk                  C Library Procedures                   Disk
  469.  
  470.  
  471.  
  472.      _p_h_y_s_i_c_a_l _f_r_a_g_m_e_n_t _i_n_d_e_x_e_s.  They do not need to be offset in  |
  473.      the same way as direct block pointers.  This applies to  any  |
  474.      block  pointer  that points to an indirect block, never to a  |
  475.      block pointer that points to a data block.                    |
  476.  
  477. PPRRIINNTTIINNGG UUTTIILLIITTIIEESS                                                 |
  478.      The last set of procedures in this package are used to print  |
  479.      out  contents  of  the  file system.  DDiisskk__PPrriinnttDDoommaaiinnHHeeaaddeerr  |
  480.      prints    out     the     domain     header     information.  |
  481.      DDiisskk__PPrriinnttSSuummmmaarryyIInnffoo  prints  out  the summary disk sector.  |
  482.      This sector is used to keep the prefix under which the  disk  |
  483.      is  exported,  the  current  number  of blocks allocated and  |
  484.      free, and whether or not the disk was safely sync'ed at last  |
  485.      reboot.              DDiisskk__PPrriinnttFFiilleeDDeessccBBiittmmaapp            and  |
  486.      DDiisskk__PPrriinnttDDaattaaBBlloocckkBBiittmmaapp print out the file descriptor  and  |
  487.      data  block  bitmaps  in  hex.  A zero bit represents a free  |
  488.      descriptor or block.  DDiisskk__PPrriinnttDDiirrEEnnttrryy prints out a direc-  |
  489.      tory entry.  DDiisskk__PPrriinnttLLffssSSuuppeerrBBlloocckk prints out the contents  |
  490.      of a LFS Super Block structure.   DDiisskk__PPrriinnttLLffssSSuuppeerrBBlloocckkHHddrr  |
  491.      prints  out  the static parameters describing the LFS layout  |
  492.      on disk.  DDiisskk__PPrriinnttLLffssCChheecckkPPooiinnttHHddrr prints out  the  struc-  |
  493.      ture   describing   and   heading  a  LFS  checkpoint  area.  |
  494.      DDiisskk__PPrriinnttLLffssCChheecckkPPooiinnttTTrraaiilleerr prints out the structure cap-  |
  495.      ping  a  LFS checkpoinit area.  DDiisskk__PPrriinnttLLffssSSttaabblleeMMeemmPPaarraammss  |
  496.      prints out  the  configuration  parameters  for  LFS  stable  |
  497.      memory  data  structures.  DDiisskk__PPrriinnttLLffssDDeessccMMaappPPaarraammss prints  |
  498.      out   the   LFS   descriptor    map    layout    on    disk.  |
  499.      DDiisskk__PPrriinnttLLffssSSeeggUUssaaggeePPaarraammss prints out the LFS segment usage  |
  500.      array       layout        description        on        disk.  |
  501.      DDiisskk__PPrriinnttLLffssFFiilleeLLaayyoouuttPPaarraammss  prints out the number of file  |
  502.      descriptors packed together per block.                        |
  503.  
  504. SSEEEE AALLSSOO                                                           |
  505.      fscheck, fsmake, labeldisk, installboot                       |
  506.  
  507. KKEEYYWWOORRDDSS                                                           |
  508.      disk, block, sector, fragment                                 |
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527. Sprite v.1.0       Printed:  November 15, 1991                  8
  528.  
  529.  
  530.  
  531.